﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.Data;
using System.Data.OracleClient;
using System.ComponentModel;
using System.Data.OleDb;
using log4net;
using System.IO;
using System.Diagnostics;
using Labs.Filtering;    
using WPFExcelReport.Events;
namespace WPFExcelReport
{
    /// <summary>
    /// Interaction logic for ArticleConditions.xaml
    /// </summary>
    public partial class ArticleConditions : Window
    {
        private CollectionViewSource wAFARBENViewSource;
        #region-------------Properties----------------------- 
        private log4net.ILog m_log_out;
        public OracleConnection myConnection;
        public OracleCommand orlReadCommand = new OracleCommand();
        public IntexReptServBLClient proxy;
        private Dictionary<string, object> dicQueryParamater;
        private Dictionary<string, object> dicParamater;
        public DataSet dsResult;
        GreigeMasterData m_GreigeMasterData;
        public DataSet dsParamaters;
        DataRow dwCurrentRecord;
        private MainWindow _Control = null;
        #endregion

        #region ----------------------------Method------------------------
        private void ReloadColorway(string ArticleNum, string ArticleVar)
        {
            DataRow dwWAFARBEN = dsParamaters.Tables["WAFARBEN"].Clone().Rows.Add();
            dwWAFARBEN["WAFART"] = ArticleNum;
            dwWAFARBEN["WAFVAR"] = ArticleVar;
            DataTable dtColor = dsParamaters.Tables["ARTICLECOLOR"];
            dtColor.Clear();
            dtColor = m_GreigeMasterData.GetGreigeColorWay(dtColor, dwWAFARBEN);
            byte[] b;
            string value;
            foreach (DataRow dw in dtColor.Rows)
            {
                foreach (DataColumn dc in dtColor.Columns)
                {
                    b = Encoding.GetEncoding("ISO-8859-1").GetBytes(dw[dc.ColumnName].ToString().Trim());
                    value = Encoding.GetEncoding("gb2312").GetString(b);
                    dw[dc.ColumnName] = value;
                }
            }
            dsParamaters.Tables["ARTICLECOLOR"].Clear();
            dsParamaters.AcceptChanges();
            dsParamaters = m_GreigeMasterData.ImportDataTable(dsParamaters, dtColor); 
            dsParamaters.AcceptChanges();
            this.listColor.DataContext = dsParamaters;
        }
        private void ReloadFinish(string ArticleNum, string ArticleVar)
        {
            DataRow dwWAFARBEN = dsParamaters.Tables["WAFARBEN"].Clone().Rows.Add();
            dwWAFARBEN["WAFART"] = ArticleNum;
            dwWAFARBEN["WAFVAR"] = ArticleVar;
            DataTable dtFinish = dsParamaters.Tables["ARTICLEFINISH"];
            dtFinish.Clear();
            dtFinish = m_GreigeMasterData.GetGreigeFinish(dtFinish, dwWAFARBEN);
            byte[] b;
            string value;
            foreach (DataRow dw in dtFinish.Rows)
            {
                foreach (DataColumn dc in dtFinish.Columns)
                {
                    b = Encoding.GetEncoding("ISO-8859-1").GetBytes(dw[dc.ColumnName].ToString().Trim());
                    value = Encoding.GetEncoding("gb2312").GetString(b);
                    dw[dc.ColumnName] = value;
                }
            }
            dsParamaters = m_GreigeMasterData.ImportDataTable(dsParamaters, dtFinish);
            dsParamaters.AcceptChanges();
            this.listFinish.DataContext = dsParamaters;
        }
        #endregion

        #region ----------------Events-----------------
        private void wAFARBENDataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (e.AddedItems.Count == 0)
                return;

            DataRowView drv = e.AddedItems[0] as DataRowView;
            if (drv == null)
                return;
            DataRow dwArticle = drv.Row;

            ReloadColorway(dwArticle["ArtNum"].ToString(), dwArticle["ArtVar"].ToString());
            ReloadFinish(dwArticle["ArtNum"].ToString(), dwArticle["ArtVar"].ToString());
            this.txtArticleNum.Text = dwArticle["ArtNum"].ToString();
            this.txtArticleVar.Text = dwArticle["ArtVar"].ToString();

        }

        private void btnQuery_Click(object sender, EventArgs e)
        {

            /*
            this.txtArticleNum.Text = "PV912102";//"07"
            this.txtArticleVar.Text = "A1";//"000012";
            this.cmbVar.Text = "A1";//"000012"; 
            this.cmbColor.Text = "黑色      ";
            this.cmbFinish.Text = "酶洗       ";
            */
            _Control.dicReportParamater.Clear();
            _Control.dicReportParamater.Add("ArticleNum", this.txtArticleNum.Text);
            _Control.dicReportParamater.Add("ArticleVar", this.txtArticleVar.Text);
            _Control.dicReportParamater.Add("ArticleColor", this.txtColor.Text);
            _Control.dicReportParamater.Add("ArticleFin", this.txtFinish.Text);
            using (new LongOperation(this, "生成工艺表"))
            {
                this.GenerateReport();
            }

        }
        void GenerateReport()
        {
            try
            {
                
                string ArticleNum = this.txtArticleNum.Text;
                string ArticleVar = this.txtArticleVar.Text;
                string ArticleColor = this.txtColor.Text;
                string ArticleFin = this.txtFinish.Text;
                dicParamater["ArticleNum"] = ArticleNum;
                dicParamater["ArticleVar"] = ArticleVar;
                dicParamater["ArticleColor"] = ArticleColor;
                dicParamater["ArticleFin"] = ArticleFin;
                string article = ArticleNum + ArticleVar + ArticleColor;
                #region GreigeMasterData
                GreigeMasterData m_GreigeMasterData = new GreigeMasterData();
                m_GreigeMasterData.myConnection = this.myConnection;
                m_GreigeMasterData.proxy = this.proxy;
                dsParamaters = m_GreigeMasterData.LoadTableStructure(dsParamaters);

                DataRow dwWAFARBEN = dsParamaters.Tables["WAFARBEN"].Clone().Rows.Add();
                dwWAFARBEN["WAFART"] = ArticleNum;
                dwWAFARBEN["WAFVAR"] = ArticleVar;
                dwWAFARBEN["WAFZUSATZ"] = ArticleColor;
                dsParamaters = m_GreigeMasterData.BuildGreigeMasterData(dsParamaters, dwWAFARBEN);
                dsParamaters = m_GreigeMasterData.ImportDataTable(dsParamaters, dsParamaters.Tables["WAFARBEN"]);

                #endregion
                this.textBox1.Text = article + " 状态：已读取坯布信息";
                #region FinishMasterData
                FinishMasterData m_fm = new FinishMasterData();
                m_fm.myConnection = this.myConnection;
                m_fm.proxy = this.proxy;

                dwWAFARBEN = dsParamaters.Tables["WAFARBEN"].Clone().Rows.Add();
                dwWAFARBEN["WAFART"] = ArticleNum;
                dwWAFARBEN["WAFVAR"] = ArticleVar;
                dwWAFARBEN["WAFZUSATZ"] = ArticleFin;
                dsParamaters = m_fm.BuildFinishMasterData(dsParamaters, dwWAFARBEN);
                dsParamaters = m_fm.ImportDataTable(dsParamaters, dsParamaters.Tables["WAFINISH"]);

                #endregion
                this.textBox1.Text = article + " 状态：已读取成品信息";
                #region WarpMasterData
                WarpMasterData m_Wm = new WarpMasterData();
                m_Wm.myConnection = this.myConnection;
                m_Wm.proxy = this.proxy;
                dsParamaters = m_Wm.LoadTableStructure(dsParamaters);
                //BSFARB / BSFKART   /BSFKVAR     /BSFKFARBE  
                DataRow dwBSFARB = dsParamaters.Tables["BSFARB"].Clone().Rows.Add();
                foreach (DataRow dwWASTKE in dsParamaters.Tables["WASTKE"].Rows)
                {
                    //WAKKART              WAKKVAR WAKKFARBE
                    dwBSFARB["BSFKART"] = dwWASTKE["WAKKART"];
                    dwBSFARB["BSFKVAR"] = dwWASTKE["WAKKVAR"];
                    dwBSFARB["BSFKFARBE"] = m_Wm.GetGB2312Value(dwWASTKE, "WAKKFARBE");
                    dsParamaters = m_Wm.BuildWarpMasterData(dsParamaters, dwBSFARB);
                }

                foreach (DataRow dwBASTKE in dsParamaters.Tables["BASTKE"].Rows)
                {
                    //WAKKART              WAKKVAR WAKKFARBE
                    dwBSFARB["BSFKART"] = dwBASTKE["BAKKART"];
                    dwBSFARB["BSFKVAR"] = dwBASTKE["BAKKVAR"];
                    dwBSFARB["BSFKFARBE"] = m_Wm.GetGB2312Value(dwBASTKE, "BAKKFARBE");
                    dsParamaters = m_Wm.BuildWarpMasterData(dsParamaters, dwBSFARB);
                }

                #endregion
                this.textBox1.Text = article + " 状态：已读取轴信息";
                #region YarnMasterData
                YarnMasterData m_YM = new YarnMasterData();
                m_YM.myConnection = this.myConnection;
                m_YM.proxy = this.proxy;
                dsParamaters = m_YM.LoadTableStructure(dsParamaters);

                bool flag = true;
                string YarnArt;
                string YarnVar;
                string YarnColor;
                DataRow dwGSCOLOR;
                DataTable dtGSCOLOR;
                dtGSCOLOR = dsParamaters.Tables["GSCOLOR"].Clone();
                while (flag)
                {
                    #region WASTGA
                    foreach (DataRow dwWASTGA in dsParamaters.Tables["WASTGA"].Rows)
                    {
                        //WAGGART              WAGGVAR WAGGFARBE  
                        YarnArt = dwWASTGA["WAGGART"].ToString();
                        YarnVar = dwWASTGA["WAGGVAR"].ToString();
                        YarnColor = m_YM.GetGB2312Value(dwWASTGA, "WAGGFARBE");
                        if (!m_YM.YarnExist(dsParamaters.Tables["GSDAT"], YarnArt, YarnVar))
                        {
                            if (!m_YM.YarnExist(dtGSCOLOR, YarnArt, YarnVar))
                            {
                                dwGSCOLOR = dtGSCOLOR.Rows.Add();
                                dwGSCOLOR["GSCART"] = YarnArt;
                                dwGSCOLOR["GSCVAR"] = YarnVar;
                                dwGSCOLOR["GSCFARBE"] = YarnColor;
                            }
                        }
                    }
                    #endregion

                    #region BASTGA
                    foreach (DataRow dwBASTGA in dsParamaters.Tables["BASTGA"].Rows)
                    {

                        //GSCOLOR/  GSCART               GSCVAR GSCFARBE  
                        YarnArt = dwBASTGA["BAGGART"].ToString();
                        YarnVar = dwBASTGA["BAGGVAR"].ToString();
                        YarnColor = m_YM.GetGB2312Value(dwBASTGA, "BAGGFARBE");
                        if (!m_YM.YarnExist(dsParamaters.Tables["GSDAT"], YarnArt, YarnVar))
                        {
                            if (!m_YM.YarnExist(dtGSCOLOR, YarnArt, YarnVar))
                            {
                                dwGSCOLOR = dtGSCOLOR.Rows.Add();
                                dwGSCOLOR["GSCART"] = YarnArt;
                                dwGSCOLOR["GSCVAR"] = YarnVar;
                                dwGSCOLOR["GSCFARBE"] = YarnColor;
                            }
                        }
                    }
                    #endregion

                    #region GASTGA
                    foreach (DataRow dwGASTGA in dsParamaters.Tables["GASTGA"].Rows)
                    {

                        YarnArt = dwGASTGA["GAGGART"].ToString();
                        YarnVar = dwGASTGA["GAGGVAR"].ToString();
                        YarnColor = dwGASTGA["GAGGFARBE"].ToString();
                        if (!m_YM.YarnExist(dsParamaters.Tables["GSDAT"], YarnArt, YarnVar))
                        {
                            if (!m_YM.YarnExist(dtGSCOLOR, YarnArt, YarnVar))
                            {
                                dwGSCOLOR = dtGSCOLOR.Rows.Add();
                                dwGSCOLOR["GSCART"] = YarnArt;
                                dwGSCOLOR["GSCVAR"] = YarnVar;
                                dwGSCOLOR["GSCFARBE"] = YarnColor;
                            }
                        }
                    }
                    #endregion
                    flag = false;
                    foreach (DataRow dwYan in dtGSCOLOR.Rows)
                    {
                        flag = true;
                        dsParamaters = m_YM.BuildYarnMasterData(dsParamaters, dwYan);
                    }
                    dtGSCOLOR.Clear();

                }
                #endregion
                this.textBox1.Text = article + " 状态：已读取纱线信息";
                #region PatternMasterData
                PatternMasterData m_PatternMasterData = new PatternMasterData();
                m_PatternMasterData.myConnection = this.myConnection;
                m_PatternMasterData.proxy = this.proxy;
                dsParamaters = m_PatternMasterData.LoadTableStructure(dsParamaters);
                //BSFARB / BSFKART   /BSFKVAR     /BSFKFARBE  
                /*DataTable dtPattern = new DataTable("Pattern");
                dtPattern.Columns.Add("PatternTable", typeof(String));
                dtPattern.Columns.Add("PatternType", typeof(String));
                dtPattern.Columns.Add("PatternKeyName", typeof(String));
                dtPattern.Columns.Add("PatternKey", typeof(String));
                dsParamaters.Tables.Add(dtPattern);*/
                DataTable dtPattern;
                if (!dsParamaters.Tables.Contains("Pattern"))
                {
                    dtPattern = new DataTable("Pattern");
                    dtPattern.Columns.Add("PatternTable", typeof(String));
                    dtPattern.Columns.Add("PatternType", typeof(String));
                    dtPattern.Columns.Add("PatternKeyName", typeof(String));
                    dtPattern.Columns.Add("PatternKey", typeof(String));
                    dsParamaters.Tables.Add(dtPattern);
                }
                else
                {
                    dtPattern = dsParamaters.Tables["Pattern"];
                    dtPattern.Clear();
                    dtPattern.AcceptChanges();
                }
                DataRow dwPattern;

                #region WarpPattern
                foreach (DataRow dwTmp in dsParamaters.Tables["BSSATZ"].Rows)
                {
                    dwPattern = dtPattern.Rows.Add();
                    dwPattern["PatternTable"] = "WTSAER";
                    dwPattern["PatternType"] = "WarpPattern";
                    dwPattern["PatternKeyName"] = "WTBSRFNR";
                    dwPattern["PatternKey"] = dwTmp["BSSRFNR"].ToString().Trim();

                }
                #endregion
                this.textBox1.Text = article + " 状态：已读经纱排花信息";
                #region SelvagePattern
                foreach (DataRow dwTmp in dsParamaters.Tables["WASTKE"].Rows)
                {
                    dwPattern = dtPattern.Rows.Add();
                    dwPattern["PatternTable"] = "WTLEIST";
                    dwPattern["PatternType"] = "SelvageLeftPattern";
                    dwPattern["PatternKeyName"] = "WTLLEIST";
                    dwPattern["PatternKey"] = dwTmp["WAKLLEIST"].ToString().Trim();
                    dwPattern = dtPattern.Rows.Add();
                    dwPattern["PatternTable"] = "WTLEIST";
                    dwPattern["PatternType"] = "SelvageRightPattern";
                    dwPattern["PatternKeyName"] = "WTLLEIST";
                    dwPattern["PatternKey"] = dwTmp["WAKRLEIST"].ToString().Trim();
                }
                #endregion
                this.textBox1.Text = article + " 状态：已布边轴信息";
                #region WeaveRepeat /Denting
                foreach (DataRow dwTmp in dsParamaters.Tables["WASTAMM"].Rows)
                {
                    dwPattern = dtPattern.Rows.Add();
                    dwPattern["PatternTable"] = "SDDAT";
                    dwPattern["PatternType"] = "WeaveRepeat";
                    dwPattern["PatternKeyName"] = "SDKEY";
                    //select * from sddat where SDSA='0109' AND SDKEY Like '%4226%V'
                    dwPattern["PatternKey"] = dwTmp["WABIND"].ToString().Trim();

                    dwPattern = dtPattern.Rows.Add();
                    dwPattern["PatternTable"] = "WTEINZ";
                    dwPattern["PatternType"] = "Denting";
                    dwPattern["PatternKeyName"] = "WTEEINZNR";
                    dwPattern["PatternKey"] = dwTmp["WAEINZNR"].ToString().Trim();

                }
                #endregion
                this.textBox1.Text = article + " 状态：已读取穿综插筘信息";
                #region WeftPattern
                foreach (DataRow dwTmp in dsParamaters.Tables["WTGEW"].Rows)
                {
                    dwPattern = dtPattern.Rows.Add();
                    dwPattern["PatternTable"] = "WTSCHUSS";
                    dwPattern["PatternType"] = "WeftPattern";
                    dwPattern["PatternKeyName"] = "WTSSFLGNR";
                    dwPattern["PatternKey"] = dwTmp["WTGSFLG"].ToString().Trim();

                }
                #endregion
                this.textBox1.Text = article + " 状态：已读取纬向排花信息";
                #region DraftingNumber

                foreach (DataRow dwTmp in dsParamaters.Tables["WASTPASS"].Rows)
                {
                    dwPattern = dtPattern.Rows.Add();
                    dwPattern["PatternTable"] = "WTPASS";
                    dwPattern["PatternType"] = "DraftingNumber";
                    dwPattern["PatternKeyName"] = "WTPPASSNR";
                    dwPattern["PatternKey"] = dwTmp["WSPPASS"].ToString().Trim();

                }
                #endregion
                this.textBox1.Text = article + " 状态：已读穿综信息";
                foreach (DataRow dwPatterns in dtPattern.Rows)
                {
                    dsParamaters = m_PatternMasterData.BuildPatternMasterData(dsParamaters, dwPatterns);
                    this.textBox1.Text = article + " 状态：已读花型信息：" + dwPatterns["PatternType"].ToString();
                }
                #endregion 
        
                this.textBox1.Text = article + " 状态：开始生成报表";
                GreigeMasterReport m_GreigeMasterReport = new GreigeMasterReport(dicParamater);
                m_GreigeMasterReport.dsSource = dsParamaters;
                m_GreigeMasterReport.GetGreigeMasterReport("EXCEL");
                this.textBox1.Text = article + "报表生成完毕"; 
            }
            catch (Exception ex)
            {
                m_log_out.Error(ex);
            }
        }
        private void listColor_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (e.AddedItems.Count == 0)
                return;
            DataRowView drv = e.AddedItems[0] as DataRowView;
            DataRow dwArticle = drv.Row;
            this.txtColor.Text = dwArticle["ArtColor"].ToString();
        }

        private void listFinish_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (e.AddedItems.Count == 0)
                return;
            DataRowView drv = e.AddedItems[0] as DataRowView;
            DataRow dwArticle = drv.Row;
            this.txtFinish.Text = dwArticle["ArtFin"].ToString();
        }
        #endregion

        #region ---------------INTERNAL------------------
        public ArticleConditions()
        {
            InitializeComponent();
        }
        public ArticleConditions(Dictionary<string, object> dicParamater)
        {
            InitializeComponent();
            this._Control = (MainWindow)dicParamater["_Control"];
            this.m_log_out = (log4net.ILog)dicParamater["m_log_out"];
            this.dicParamater = dicParamater; 
            this.txtArticleNum.Text = "请选择品种";//"07"
            /*this.txtArticleVar.Text = "A1";//"000012";
            this.txtColor.Text = "RD01      ";
            this.txtFinish.Text = "F01";*/

        }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            try
            {
                //dsParamaters = ((IntexReportClient.DataSetIntex)(this.FindResource("dataSetIntex")));
                InitDataBinding();
                orlReadCommand = myConnection.CreateCommand();
                orlReadCommand.CommandText = "SELECT Distinct WAART as  ArtNum, WAVAR as ArtVar,WABEZ as ArtDes"
               + " FROM INTEX.WASTAMM WHERE  WAKUNDNR='00000000' AND WAART like '%%' order by 1 desc";

                dsResult = m_GreigeMasterData.Connect2Proxy(orlReadCommand);

                if (dsResult.Tables.Count > 0)
                {
                    dsResult.Tables[0].TableName = "ARTICLE";

                    byte[] b;
                    string value;
                    foreach (DataRow dw in dsResult.Tables[0].Rows)
                    {
                        b = Encoding.GetEncoding("ISO-8859-1").GetBytes(dw["ArtDes"].ToString().Trim());
                        value = Encoding.GetEncoding("gb2312").GetString(b);
                        dw["ArtDes"] = value;
                    }
                    foreach (DataTable dtTemp in dsResult.Tables)
                    {  
                        dsParamaters = m_GreigeMasterData.ImportDataTable(dsParamaters, dtTemp); 
                    } 
                }
                dsParamaters.AcceptChanges();
                this.DataContext = dsParamaters; 
            }
            catch (Exception ex)
            {
                this.m_log_out.Error(ex);
            }
            return;

        }
        private void InitDataBinding()
        {
            m_GreigeMasterData = new GreigeMasterData();
            m_GreigeMasterData.myConnection = this.myConnection;
            m_GreigeMasterData.proxy = this.proxy;

            this.dsParamaters.Tables.Add("ARTICLE");
            this.dsParamaters.Tables.Add("ARTICLEVAR");
            this.dsParamaters.Tables.Add("ARTICLECOLOR");
            this.dsParamaters.Tables.Add("ARTICLEFINISH");
            orlReadCommand = myConnection.CreateCommand();

            #region "ARTICLE"
            orlReadCommand.CommandText = "SELECT WAART AS ArtNum, WAVAR as ArtVar,WABEZ as ArtDes"
            + " FROM INTEX.WASTAMM WHERE RowNum<1";

            dsResult = m_GreigeMasterData.Connect2Proxy(orlReadCommand);

            if (dsResult.Tables.Count > 0)
            {
                dsResult.Tables[0].TableName = "ARTICLE";

                foreach (DataTable dtTemp in dsResult.Tables)
                {
                    dsParamaters = m_GreigeMasterData.ImportDataTable(dsParamaters, dtTemp); 
                }
            }
            #endregion 

            #region "ARTICLECOLOR"
            orlReadCommand.CommandText = "SELECT WAFART as ArtNum,	WAFVAR as ArtVar,	 WAFZUSATZ as ArtColor,WAFBEZ as ColorDes"
                + " FROM INTEX.WAFARBEN WHERE RowNum<1";

            dsResult = m_GreigeMasterData.Connect2Proxy(orlReadCommand);

            if (dsResult.Tables.Count > 0)
            {
                dsResult.Tables[0].TableName = "ARTICLECOLOR";

                foreach (DataTable dtTemp in dsResult.Tables)
                {

                    dsParamaters = m_GreigeMasterData.ImportDataTable(dsParamaters, dtTemp); 
                }
            }
            #endregion

            #region "ARTICLEFINISH"

            orlReadCommand.CommandText = "SELECT WAFART as ArtNum,	WAFVAR as ArtVar,	 WAFZUSATZ as ArtFin,WAFBEZ as FinishDes"
          + " FROM INTEX.WAFARBEN WHERE RowNum<1";

            dsResult = m_GreigeMasterData.Connect2Proxy(orlReadCommand);

            if (dsResult.Tables.Count > 0)
            {
                dsResult.Tables[0].TableName = "ARTICLEFINISH";

                foreach (DataTable dtTemp in dsResult.Tables)
                {

                    dsParamaters = m_GreigeMasterData.ImportDataTable(dsParamaters, dtTemp); 
                }
            }
            #endregion

            #region "WAFARBEN"
            orlReadCommand.CommandText = "SELECT * "
    + " FROM INTEX.WAFARBEN WHERE RowNum<1";

            dsResult = m_GreigeMasterData.Connect2Proxy(orlReadCommand);

            if (dsResult.Tables.Count > 0)
            {
                dsResult.Tables[0].TableName = "WAFARBEN";

                foreach (DataTable dtTemp in dsResult.Tables)
                {

                    dsParamaters = m_GreigeMasterData.ImportDataTable(dsParamaters, dtTemp);
                }
            }
            #endregion

            #region "Combo" 
            dsParamaters.AcceptChanges();
            this.wAFARBENDataGrid.DataContext = dsParamaters;
            #endregion
        }
        #endregion       
    }
}
